<html>
<head><meta charset="utf-8"><title>Liveness analysis- &quot;Used&quot; designation · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Liveness.20analysis-.20.22Used.22.20designation.html">Liveness analysis- &quot;Used&quot; designation</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="213379429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Liveness%20analysis-%20%22Used%22%20designation/near/213379429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliviacrain <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Liveness.20analysis-.20.22Used.22.20designation.html#213379429">(Oct 15 2020 at 04:30)</a>:</h4>
<p>Hi y'all- wondering if anyone familiar with the liveness pass can help out here. I'm looking at <a href="https://github.com/rust-lang/rust/issues/77915">this issue</a> and I'm having a bit of a hard time understanding some of the nuances in liveness analysis. Specifically, I'm not sure I get the difference between a variable being read and a variable being used <a href="https://github.com/rust-lang/rust/blob/f42692b1cc1552abf905f9b6650061d246024252/compiler/rustc_passes/src/liveness.rs#L74-L77">(in the context of the RWU struct)</a>. </p>
<p>The gist of the bug is that variables used in <code>InOut</code> operands in inline assembly <a href="https://doc.rust-lang.org/beta/unstable-book/library-features/asm.html#operand-type">(that is, they're used as both input and output to some arbitrary assembly instruction)</a> are being marked as read and written to, but are not marked as being used. This can result in such expressions triggering an <code>unused variable</code> lint warning.</p>
<p>It makes intuitive sense to me that a variable being used both as an input and an output to an arbitrary assembly instruction counts as a use- I feel like it fits the bill of "some read that is not just used to generate a new value". Am I on the right track there, or is there more nuance to a variable being marked as used?</p>



<a name="213380102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Liveness%20analysis-%20%22Used%22%20designation/near/213380102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Liveness.20analysis-.20.22Used.22.20designation.html#213380102">(Oct 15 2020 at 04:47)</a>:</h4>
<p>I don't know anything about this part of the compiler, but I'd guess that "read" is what llvm thinks and "use" is what rustc thinks</p>



<a name="213380105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Liveness%20analysis-%20%22Used%22%20designation/near/213380105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Liveness.20analysis-.20.22Used.22.20designation.html#213380105">(Oct 15 2020 at 04:47)</a>:</h4>
<p>Or in other words, there's some rustc pass that's buggy and ignores this intrinsic</p>



<a name="213381414"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Liveness%20analysis-%20%22Used%22%20designation/near/213381414" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliviacrain <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Liveness.20analysis-.20.22Used.22.20designation.html#213381414">(Oct 15 2020 at 05:19)</a>:</h4>
<p>Thanks! Luckily I think it's simpler than that- just a small semantic difference meant to help diagnose finer-grained warnings.</p>



<a name="213404091"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Liveness%20analysis-%20%22Used%22%20designation/near/213404091" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Liveness.20analysis-.20.22Used.22.20designation.html#213404091">(Oct 15 2020 at 10:14)</a>:</h4>
<p>The compound assignment is currently the only use-case for having both read &amp; use. For assembly we should conservatively assume that anything that is being read is also used.</p>



<a name="213424239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Liveness%20analysis-%20%22Used%22%20designation/near/213424239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliviacrain <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Liveness.20analysis-.20.22Used.22.20designation.html#213424239">(Oct 15 2020 at 13:24)</a>:</h4>
<p>Awesome- glad it's a lot less nuanced than I thought. Thanks!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>